/**
 * Created by hefan on 16/11/18.
 */

/* 对象数组检索*/
function search(arr,str) {
  let res = str
  for( let i of arr){
    if(i.value === str){
      res = i.label
    }
  }
  return res
}

export let shipStat = [{
    value: '',
    label: ''
  }, {
    value: 'E',
    label: '预报'
  }, {
    value: 'C',
    label: '确报'
  }, {
    value: 'A',
    label: '抵锚'
  }, {
    value: 'Y',
    label: '到港'
  }, {
    value: 'L',
    label: '离港'
  }]

/* 格式化船舶状态*/
export function formattingShipStat(str) {
  let res = str
  res = search(shipStat,str)
  return res
}

export let tradeId = [{
    value: '',
    label: ''
  }, {
    value: '0',
    label: '内外贸'
  }, {
    value: '1',
    label: '外贸'
  }, {
    value: '2',
    label: '内贸'
  }]

/* 格式化内外贸*/
export function formattingTradeId(str) {
  let res = str
  res = search(tradeId,str)
  return res
}

export let workTyp = [{
    value: '',
    label: ''
  }, {
    value: 'SI',
    label: '卸船'
  }, {
    value: 'SO',
    label: '装船'
  }]

/* 格式化作业类型*/
export function formattingWorkTyp(str) {
  let res = str
  res = search(workTyp,str)
  return res
}

export let commStatus = [{
    value: '',
    label: ''
  }, {
    value: '1',
    label: '计划状态'
  }, {
    value: '2',
    label: '已发送无车'
  }, {
    value: '3',
    label: '已发送有车'
  }, {
    value: '4',
    label: '在车'
  }, {
    value: '5',
    label: '已完成'
  }]

/* 格式化作业类型*/
export function formattingCommStatus(str) {
  let res = str
  res = search(commStatus,str)
  return res
}

export let currentStat = [{
    value: '',
    label: ''
  }, {
    value: '0',
    label: '离港'
  }, {
    value: '1',
    label: '预报'
  }, {
    value: '2',
    label: '在场'
  }, {
    value: '3',
    label: '离场'
  }, {
    value: '4',
    label: '在车'
  }, {
    value: '5',
    label: '在船'
  }, {
    value: '6',
    label: '在卡'
  }]

/* 格式化作业类型*/
export function formattingCurrentStat(str) {
  let res = str
  res = search(currentStat,str)
  return res
}
export let cntrClass = [{
    value: '',
    label: ''
  }, {
    value: 'A',
    label: '过驳箱'
  }, {
    value: 'E',
    label: '出口箱'
  }, {
    value: 'F',
    label: '同船落地移动'
  }, {
    value: 'I',
    label: '进口箱'
  }, {
    value: 'M',
    label: '存储箱'
  }, {
    value: 'P',
    label: '退关箱'
  }, {
    value: 'R',
    label: '同船移动'
  }, {
    value: 'S',
    label: '同船禁移'
  }, {
    value: 'T',
    label: '中转箱'
  }]

/* 格式化作业类型*/
export function formattingCntrClass(str) {
  let res = str
  res = search(cntrClass,str)
  return res
}

export let messageQueue = [{
    value: '',
    label: ''
  }, {
    value: 'illegalMessage',
    label: '非法消息'
  }, {
    value: 'illegalRequest',
    label: '非法请求'
  }, {
    value: 'shipVisitUpdate',
    label: '船舶来港更新'
  }, {
    value: 'shipGeometryRequest',
    label: '船舶结构请求'
  }, {
    value: 'shipGeometryMessage',
    label: '船舶结构消息'
  }, {
    value: 'shipGeometryAnalysis',
    label: '船舶结构分析'
  }, {
    value: 'shipInventoryRequest',
    label: '船舶清单请求'
  }, {
    value: 'shipInventoryMessage',
    label: '船舶清单消息'
  }, {
    value: 'shipInventoryUpdate',
    label: '船舶清单更新'
  }, {
    value: 'workQueuesRequest',
    label: '作业队列请求'
  }, {
    value: 'workQueuesMessage',
    label: '作业队列消息'
  }, {
    value: 'workQueueUpdate',
    label: '作业队列更新'
  }, {
    value: 'workQueuePlanUpdate',
    label: '作业队列计划更新'
  }, {
    value: 'workQueueActivation',
    label: '作业队列激活'
  }, {
    value: 'containerPickSet',
    label: '集装箱拾取放置'
  }, {
    value: 'vehicleInTransit',
    label: '集卡车在路'
  }, {
    value: 'vehicleArrival',
    label: '集卡车到达'
  }, {
    value: 'vehicleAlignment',
    label: '集卡车校准'
  }, {
    value: 'craneLaneSelection',
    label: '岸桥车道选择'
  }]

/* 格式化作业类型*/
export function formattingMessageQueue(str) {
  let res = str
  res = search(messageQueue,str)
  return res
}
